package com.college.common.utils.security;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.Map;
import java.util.TreeMap;

public class SHA1Util {
    //sha1加密
    public static String sha1(String appkey,Map<String, Object> params) {
            TreeMap<String, Object> treeMap = new TreeMap<>(params);
            treeMap.put("appkey", appkey);
            StringBuilder str = new StringBuilder();
            treeMap.forEach((key, value) -> str.append(key).append("=").append(value).append("&"));
            String tmp = str.substring(0, str.length() - 1);
            return DigestUtils.sha1Hex(tmp);
    }


}
